<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改药品管理')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-medication-edit" th:object="${tMedication}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">药品名称：</label>
            <div class="col-sm-8">
                <input name="name" disabled th:field="*{name}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">单位：</label>
            <div class="col-sm-8">
                <select name="unit" class="form-control m-b" th:with="type=${@dict.getType('hospital_medication_unit')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                            th:field="*{unit}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">单价：</label>
            <div class="col-sm-8">
                <input name="price" th:field="*{price}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">生产日期：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="manufactureDate"
                           th:value="${#dates.format(tMedication.manufactureDate, 'yyyy-MM-dd HH:mm:ss')}"
                           class="form-control layui-datetime" placeholder="yyyy-MM-dd HH:mm:ss" type="text" required>
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">有效日期：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="effectiveDate"
                           th:value="${#dates.format(tMedication.effectiveDate, 'yyyy-MM-dd HH:mm:ss')}"
                           class="form-control layui-datetime" placeholder="yyyy-MM-dd HH:mm:ss" type="text" required>
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">批号：</label>
            <div class="col-sm-8">
                <input name="batchNumber" th:field="*{batchNumber}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">类型：</label>
            <div class="col-sm-8">
                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('hospital_medication_type')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                            th:field="*{type}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">库存数量：</label>
            <div class="col-sm-8">
                <input name="inventory" th:field="*{inventory}" class="form-control" type="text" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "hospital/medication";
    $("#form-medication-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-medication-edit').serialize());
        }
    }

</script>
</body>
</html>